home *** CD-ROM | disk | FTP | other *** search
/ Aminet 39 / Aminet 39 (2000)(Schatztruhe)[!][Oct 2000].iso / Aminet / mus / misc / AampPlaylistCo.lha / AampPlaylistConvert-r / AampPlaylistConvert-r.cpp < prev    next >
C/C++ Source or Header  |  2000-08-13  |  4KB  |  114 lines

  1. #include <fstream.h>
  2.  
  3. char *vers = "$VER: AampPlaylistConvert-r 1.1 [13. August 2000]";
  4.  
  5. int errors=0;
  6.  
  7. int main(int argc, char **argv)
  8. {
  9.     short idx=0, idx2=0, contin=1;
  10.     char buffer[500], path[200], artist[31], title[31], seconds[6];
  11.     fstream ein, aus;
  12.     cout <<"|  AampPlaylistConvert-r 1.1  |"<<endl;
  13.     cout <<"| by radiat-r@Sascha-Ploss.de |"<<endl;
  14.     if (argc == 3)
  15.     {
  16.         ein.open(argv[1],ios::in);
  17.         if (ein.is_open())
  18.         {
  19.             aus.open(argv[2],ios::out);
  20.             if (aus.is_open())
  21.             {
  22.                 ein.getline(buffer,500);
  23.                 while (!ein.eof() && contin)
  24.                 {
  25.                     idx=0;
  26.                     while ((buffer[idx] != '\t') && (buffer[idx] != '\0'))
  27.                     {
  28.                         path[idx]=buffer[idx];
  29.                         idx++;
  30.                     }
  31.                     if (buffer[idx] != '\0')
  32.                     {
  33.                         path[idx]='\0';
  34.                         idx++;
  35.                         idx2=0;
  36.                         while (!((buffer[idx] == ' ') && (buffer[idx+1] == '-') && (buffer[idx+2] == ' ')) && (buffer[idx] != '\0'))
  37.                         {
  38.                             artist[idx2]=buffer[idx];
  39.                             idx++;
  40.                             idx2++;
  41.                         }
  42.                         if (buffer[idx] != '\0')
  43.                         {
  44.                             artist[idx2]='\0';
  45.                             idx+=3;
  46.                             idx2=0;
  47.                             while ((buffer[idx] != '\t') && (buffer[idx] != '\0'))
  48.                             {
  49.                                 title[idx2]=buffer[idx];
  50.                                 idx++;
  51.                                 idx2++;
  52.                             }
  53.                             if (buffer[idx] != '\0')
  54.                             {
  55.                                 title[idx2]='\0';
  56.                                 idx++;
  57.                                 idx2=0;
  58.                                 while ((buffer[idx] != ' ') && (buffer[idx] != '\0'))
  59.                                 {
  60.                                     seconds[idx2]=buffer[idx];
  61.                                     idx++;
  62.                                     idx2++;
  63.                                 }
  64.                                 if (buffer[idx] != '\0')
  65.                                 {
  66.                                     seconds[idx2]='\0';
  67.                                     aus <<path<<"\t"<<artist<<"\t"<<title<<"\t"<<seconds<<" seconds"<<endl;  // You can change this line to produce your own output format
  68.                                     ein.getline(buffer,200);
  69.                                 }
  70.                                 else
  71.                                 {
  72.                                     cout <<"Error, either inputfile does not need to be converted or is not a playlistfile at all."<<endl;
  73.                                     contin=0;
  74.                                 }
  75.                             }
  76.                             else
  77.                             {
  78.                                 cout <<"Error, either inputfile does not need to be converted or is not a playlistfile at all."<<endl;
  79.                                 contin=0;
  80.                             }
  81.                         }
  82.                         else
  83.                         {
  84.                             cout <<"Error, either inputfile does not need to be converted or is not a playlistfile at all."<<endl;
  85.                             contin=0;
  86.                         }
  87.                     }
  88.                     else
  89.                     {
  90.                         cout <<"Error, either inputfile does not need to be converted or is not a playlistfile at all."<<endl;
  91.                         contin=0;
  92.                     }
  93.                 }
  94.             }
  95.             else // aus.is_open
  96.             {
  97.                 cout <<"Error while opening outputfile: "<<argv[2]<<endl;
  98.                 errors++;
  99.             }
  100.         }
  101.         else // ein.is_open
  102.         {
  103.             cout <<"Error while opening inputfile: "<<argv[1]<<endl;
  104.             errors++;
  105.         }
  106.     }
  107.     else // argc >< 3
  108.     {
  109.         cout <<"Error, wrong number of arguments,\nUsage: "<<argv[0]<<" Inputfile Outputfile"<<endl;
  110.         errors++;
  111.     }
  112.     return errors;
  113. }
  114.